﻿Type=Activity
Version=2.71
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.
	Dim V_XM As String
	Dim V_XB As String
	Dim V_SQDH As Int
	Dim V_BHID As Int
	Dim FSQDH As Int
	Dim FBGData As String
	
End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.

	Dim wbvJCBG As WebView
	
	Dim HttpJobTool As HttpJob
End Sub

Sub Activity_Create(FirstTime As Boolean)
	Activity.LoadLayout("FormBHJCBGInfo")
	
	Activity.Title = "病人检查申请单信息-"  & V_XM & " " &V_XB 
	
	InitLayOut

End Sub

Sub Activity_Resume
	If FSQDH<>V_SQDH Then
		RefreshData
	Else
		wbvJCBG.LoadHtml(FBGData)
	End If
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub InitLayOut

	'高级菜单
	Activity.AddMenuItem("住院/门诊号","MenuItemAdv")
	'Activity.AddMenuItem("姓名","MenuItemAdv")
	'Activity.AddMenuItem("设置","MenuItemAdv")

	Activity.AddMenuItem("选择处理类别","MenuItemAdv")

End Sub

Sub MenuItemAdv_Click
	If Sender = "住院/门诊号" Then
		BHList.V_ZYH = ""
		StartActivity("BHSearch") 
		
	Else If Sender = "选择处理类别" Then
		StartActivity("SelectCLLB") 
	End If
	
End Sub

Sub RefreshData
	Dim sURL,sSession,sBHID,sSQDH,sText As String
	
	sSession = PublicVar.GV_DesTool.Base64encrypt(PublicVar.GV_UserSession)
	
	sSQDH = PublicVar.GV_DesTool.Base64encrypt(V_SQDH)
	sBHID = PublicVar.GV_DesTool.Base64encrypt(V_BHID)
	
	sText = "Session=" & sSession & "&SQDH=" & sSQDH & "&BHID=" & sBHID

	sURL = PublicVar.GetServerUrl&"/getyjsqdinfo"

	HttpJobTool.Initialize("Job1",Me)
	HttpJobTool.PostString(sURL,sText)
	
	ProgressDialogShow("正在获取数据，请稍候...")	

End Sub

Sub JobDone (Job As HttpJob)
   Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
   If Job.Success = True Then
      If Job.JobName = "Job1" Then
				LoginSuccess(Job)
      End If
   Else
		LoginError(Job)
   End If
   Job.Release
End Sub

Sub LoginSuccess(Job As HttpJob)   
	Dim sResult,sCode,sData As String
	Dim mapResult As Map
	
	ProgressDialogHide
	sResult = Job.GetString.Trim
	
	PublicVar.GV_JSonTool.Initialize(sResult)
	mapResult = PublicVar.GV_JSonTool.NextObject
	
	sCode = mapResult.Get("Code")
	If sCode<>"0" Then
		sResult = mapResult.Get("Message")
		ToastMessageShow("获取数据失败"&CRLF &sResult, True)	
		Return
	End If
	
	sData = mapResult.Get("Data")
	If sData ="" Then
		ToastMessageShow("获取数据失败"&CRLF &"返回的数据为空", True)	
		Return	
	
	End If
	
	sData = PublicVar.GV_DesTool.Base64decrypt(sData)
	If wbvJCBG.IsInitialized Then
		wbvJCBG.LoadHtml(sData)
		FBGData = sData
		FSQDH = V_SQDH
	End If
End Sub

Sub LoginError(Job As HttpJob)  
	Dim sMsg As String
	ProgressDialogHide
	
  Log("Error: " & Job.ErrorMessage)
	sMsg = "获取检查报告失败."& CRLF & Job.ErrorMessage 
  ToastMessageShow(sMsg, True)
End Sub


